﻿namespace OboutInc.EasyMenu_Pro
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI;

    public class MenuItemCollectionData : List<MenuItemData>, IStateManager
    {
        private bool _marked = false;

        public void LoadViewState(object state)
        {
            if (state != null)
            {
                Pair pair = (Pair) state;
                base.Clear();
                Pair first = (Pair) pair.First;
                Pair second = (Pair) pair.Second;
                Pair pair4 = (Pair) second.First;
                string[] strArray = (string[]) first.First;
                string[] strArray2 = (string[]) first.Second;
                string[] strArray3 = (string[]) pair4.First;
                string[] strArray4 = (string[]) pair4.Second;
                string[] strArray5 = (string[]) second.Second;
                for (int i = 0; i < strArray.Length; i++)
                {
                    base.Add(new MenuItemData(strArray[i], strArray2[i], strArray3[i], strArray4[i], strArray5[i]));
                }
            }
        }

        public object SaveViewState()
        {
            int count = base.Count;
            object[] x = new string[count];
            object[] y = new string[count];
            object[] objArray3 = new string[count];
            object[] objArray4 = new string[count];
            object[] objArray5 = new string[count];
            for (int i = 0; i < count; i++)
            {
                x[i] = base[i].DataIdField;
                y[i] = base[i].DataTextField;
                objArray3[i] = base[i].DataUrlField;
                objArray4[i] = base[i].DataParentIdField;
                objArray5[i] = base[i].DataUrlTargetField;
            }
            Pair pair = new Pair(x, y);
            Pair pair2 = new Pair(objArray3, objArray4);
            return new Pair(pair, new Pair(pair2, objArray5));
        }

        public void TrackViewState()
        {
            this._marked = true;
        }

        public bool IsTrackingViewState
        {
            get
            {
                return this._marked;
            }
        }
    }
}

